cd "./APSR Replication/"

use "./Original Survey Files/MALAWI_HEAD_TEACHER_BASELINE.dta"
gen Priority1="Classrooms" if mlw03_q63_1=="Change room more especially for girl" | mlw03_q63_1=="Class rooms" | mlw03_q63_1=="Classroom" | mlw03_q63_1=="Classroom block" | mlw03_q63_1=="Classroom blocks" | mlw03_q63_1=="Classroom blocks and teachers houses" | mlw03_q63_1=="Classroom buildings" | mlw03_q63_1=="Classrooms" | mlw03_q63_1=="Classrooms blocks" | mlw03_q63_1=="Improvement on classrooms" | mlw03_q63_1=="More classroom blocks" | mlw03_q63_1=="More school blocks" | mlw03_q63_1=="Not enough school blocks" | mlw03_q63_1=="Rehabilitation of school block" | mlw03_q63_1=="School block" | mlw03_q63_1=="School block construction" | mlw03_q63_1=="School block's" | mlw03_q63_1=="School blocka" | mlw03_q63_1=="School blocks" | mlw03_q63_1=="School bocks" | mlw03_q63_1=="school block" | mlw03_q63_1=="school blocks"
replace Priority1="Desks/Furniture" if mlw03_q63_1=="Desk" | mlw03_q63_1=="Desks" | mlw03_q63_1=="Furniture"
replace Priority1="Electricity" if mlw03_q63_1=="Electricity"
replace Priority1="Hire Teachers/Staff" if mlw03_q63_1=="Staffmembers" | mlw03_q63_1=="Teachers" | mlw03_q63_1=="Enough teachers" | mlw03_q63_1=="Inadequate teachers" | mlw03_q63_1=="More teachers" | strpos(mlw03_q63_1,"Staff  members")
replace Priority1="Meals Program" if mlw03_q63_1=="School feeding program" | mlw03_q63_1=="School feeding programme" | mlw03_q63_1=="School meals programme" | mlw03_q63_1=="School meal"
replace Priority1="Teacher Offices/Staff Room" if strpos(mlw03_q63_1,"Office") | strpos(mlw03_q63_1,"office")
replace Priority1="Other Infrastructure" if mlw03_q63_1=="Brick fence around the school" | mlw03_q63_1=="Library" | mlw03_q63_1=="Storeroom" | strpos(mlw03_q63_1,"Road")
replace Priority1="Teacher Housing" if mlw03_q63_1=="Houses for teacher" | mlw03_q63_1=="Teacher houses" | mlw03_q63_1=="Teacher's houses" | mlw03_q63_1=="Head teachers house" | mlw03_q63_1=="Headteacher house" | mlw03_q63_1=="Houses for school teacher" | mlw03_q63_1=="Teachers Houses" | mlw03_q63_1=="Teachers houses"
replace Priority1="Textbooks/Learning Materials" if mlw03_q63_1=="Enough teaching and learning materials" | mlw03_q63_1=="Exercise books" | mlw03_q63_1=="Learning materials" | mlw03_q63_1=="Learning resources" | mlw03_q63_1=="Teacher and learning materials" | mlw03_q63_1=="Teaching materials" | mlw03_q63_1=="Text books" | mlw03_q63_1=="Books" | mlw03_q63_1=="Lack of textbooks" | mlw03_q63_1=="Learning and teaching materials" | mlw03_q63_1=="Learning and teaching resources" | mlw03_q63_1=="Teacher and learning material" | mlw03_q63_1=="Teaching and learning materials" | mlw03_q63_1=="Teaching and learning resources" | mlw03_q63_1=="Teaching learning needs" | mlw03_q63_1=="Text book"
replace Priority1="Toilets" if mlw03_q63_1=="Learners toilets" | mlw03_q63_1=="Toilet" | mlw03_q63_1=="Learners toilet" | mlw03_q63_1=="Toikets" | mlw03_q63_1=="Toilets"
replace Priority1="Unclear/Other/Missing" if mlw03_q63_1=="Land for the school" | strpos(mlw03_q63_1,"Junior") | mlw03_q63_1==""
replace Priority1="Water Source" if strpos(mlw03_q63_1,"Water") | strpos(mlw03_q63_1,"water") | strpos(mlw03_q63_1,"Borehole")

replace mlw03_q63_2="Office" if  mlw03_q63_2=="Administration block" | mlw03_q63_2=="Teachers block" | mlw03_q63_2=="Office block" | mlw03_q63_2=="Teachers blocks"
gen Priority2="Desks/Furniture" if strpos(mlw03_q63_2,"desk") | strpos(mlw03_q63_2,"Desk") | strpos(mlw03_q63_2,"Furniture")
replace Priority2="Hire Teachers/Staff" if mlw03_q63_2=="Enough teacher's" | mlw03_q63_2=="Shortage of teachers" | mlw03_q63_2=="Teachers" | mlw03_q63_2=="Teacher" | mlw03_q63_2=="Teacher s"
replace Priority2="Meals Program" if strpos(mlw03_q63_2,"Feeding") | strpos(mlw03_q63_2,"feeding") | strpos(mlw03_q63_2,"meal")
replace Priority2="Other Infrastructure" if mlw03_q63_2=="Infrastructure improvement" | mlw03_q63_2=="Roof" | mlw03_q63_2=="Library" | mlw03_q63_2=="Lubrary" | strpos(mlw03_q63_2,"Wall") | mlw03_q63_2=="Storeroom"
replace Priority2="Teacher Housing" if strpos(mlw03_q63_2,"House") | strpos(mlw03_q63_2,"house")
replace Priority2="Teacher Offices/Staff Room" if strpos(mlw03_q63_2,"Office") | strpos(mlw03_q63_2,"office") | strpos(mlw03_q63_2,"Staff room") | strpos(mlw03_q63_2,"staffroom")
replace Priority2="Textbooks/Learning Materials" if strpos(mlw03_q63_2,"material") | strpos(mlw03_q63_2,"resource") | strpos(mlw03_q63_2,"book") | strpos(mlw03_q63_2,"equipment")
replace Priority2="Toilets" if strpos(mlw03_q63_2,"Latrines") | strpos(mlw03_q63_2,"toilet") | strpos(mlw03_q63_2,"Toilet")
replace Priority2="Water Source" if strpos(mlw03_q63_2,"Water") | strpos(mlw03_q63_2,"water") | strpos(mlw03_q63_2,"Bore")
replace Priority2="Electricity" if strpos(mlw03_q63_2,"Electri") | strpos(mlw03_q63_2,"Solar")
replace Priority2="Classrooms" if strpos(mlw03_q63_2,"block") | strpos(mlw03_q63_2,"Classroom") | strpos(mlw03_q63_2,"classroom")
replace Priority2="Unclear/Other/Missing" if mlw03_q63_2=="School" | mlw03_q63_2=="Teachers. Houses" | strpos(mlw03_q63_2,"Painting") | mlw03_q63_2==""
tab Priority1
tab Priority2
cd "./Data"
export delimited using "headteacher_survey", replace
